# -*- coding: utf-8 -*-
'''
Created on 2011. 3. 7.

@author: blueneti
'''

# wxPython용 모듈 
import wx
import LottoAddEditUI

#추후에 계속 컨트롤를 추가하게됨
class MyFrame(wx._windows.Frame):
    def __init__(self, parent, wID, title):
        #부모의 wx._windows.Frame의 생성자를 호출
        wx._windows.Frame.__init__(self, parent, wID, title,
                                    wx.DefaultPosition,
                                    wx.Size(400, 100))

        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour(wx.Color(255,255,255))
        panel.SetAutoLayout(True)

        #Box안에 수평 방향으로 채워넣음        
        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(wx.StaticText(panel, -1, '회차: '), 0,
                wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE)
        box.Add(wx.ComboBox(panel, -1, '', wx.DefaultPosition, wx.DefaultSize, ''), 1,
                wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
        idAddPrdictButton = wx.NewId()
        box.Add(wx.Button(panel, idAddPrdictButton, 'ADD Predict'), 1,
                wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
        idAnalysisButton = wx.NewId()
        box.Add(wx.Button(panel, idAnalysisButton, 'Analysis'), 1,
                wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
        
        panel.SetSizer(box)
        
        #Frame닫힐 때에 OnCloseWindow를 호출하여 instance 종료함
        wx.EVT_CLOSE(self, self.OnCloseWindow)
        wx.EVT_BUTTON(self, idAddPrdictButton, self.OnClickAddPredict)
        wx.EVT_BUTTON(self, idAnalysisButton, self.OnClickAnalysis)


    def OnCloseWindow(self, event):
        self.Destroy()
        
    def OnClickAddPredict(self, event):
        #self.MessageBox('Add Predict Selected')
        dlg = LottoAddEditUI.LottoAddEditFrame(self,-1, "Add Lotto Predicts")
        dlg.setOwner('Blueneti')
        #dlg.ShowModal()
        dlg.CenterOnParent()
        #dlg.Parent.Enable(False)
        dlg.MakeModal(True)
        dlg.Show()
        self.MessageBox(dlg.getWeek())
    
    def OnClickAnalysis(self, event):
        pass
    
    def MessageBox(self, msg):
        dialog = wx._windows.MessageDialog(self, msg, 'Info',
                                           wx.OK|wx.ICON_INFORMATION)
        dialog.ShowModal()
        dialog.Destroy()

class MyApp(wx.App):
    def __init__(self, redirect=False):
        wx.App.__init__(self, redirect)

    def OnInit(self):
        # Frame 생성
        frame = MyFrame(None, -1, "BoxSizer")
        frame.Center() # 화면 중앙에 배치
        frame.Show(True)
        self.SetTopWindow(frame)
        return True


if __name__ == '__main__':
    app = MyApp() #객체 생성
    app.MainLoop() # event 처리하는 무한 루프